﻿using Microsoft.EntityFrameworkCore;
using ServerManager.Data;
using ServerManager.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ServerManager.Repository
{
    public class ServerRepository : EfRepository<Server>, IServerRepository
    {
        private readonly ApplicationDbContext _dbContext;

        public ServerRepository(ApplicationDbContext dbContext)
            : base(dbContext)
        {
            _dbContext = dbContext;
        }

        public async Task<Server> GetById(int id)
        {
            var server = await _dbContext.Servers.Include(x => x.IpAddresses).Include(x => x.Apps).Where(x => x.Id == id).FirstOrDefaultAsync();
            return server;
        }
    }
}
